package com.it.myh;

import java.util.Comparator;
import java.util.function.Consumer;

/**
 * @Description: // 类说明，在创建类时要填写
 * @ClassName: Od_0415_01    // 类名，会自动填充
 * @Author: MYH          // 创建者
 * @Date: 2023/4/15 16:22   // 时间
 * @Version: 1.0     // 版本
 */
public class Od_0415_01 {

    public static void main(String[] args) {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {

                System.out.println("加油！");
            }
        };
        runnable.run();
        System.out.println("-----------------------------");
        Runnable runnable1 = () -> System.out.println("加油");
        runnable1.run();

        Consumer<String> consumer = new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        };
        consumer.accept("加油!");

        Consumer<String> consumer1 = s -> {
            System.out.println(s);
        };
        consumer1.accept("马宇辉");

        Comparator<Integer> comparator =new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                System.out.println(o1);
                System.out.println(o2);
                return o1.compareTo(o2);
            }
        };
        System.out.println(comparator.compare(1,2));

        Comparator<Integer> comparator1 = (o1 , o2) ->{
            System.out.println(o1);
            System.out.println(o2);
            return o1.compareTo(o2);
        };
        System.out.println(comparator1.compare(2,1));


        Comparator<Integer> comparator2 = (o1,o2) -> o1.compareTo(o2);
        System.out.println(comparator2.compare(1,2));
    }
}
